package com.pin.zheng.xingmulibrary.util;

import android.content.Intent;
import android.util.Log;

public class Utils {
    // 两次点击按钮之间的点击间隔不能少于1000毫秒
//    private static final int MIN_CLICK_DELAY_TIME = 1000;
    private static final int MIN_CLICK_DELAY_TIME = 100;
    private static long lastClickTime;
    private static long lastClickTime2;
    private static int pos;
    private static int pos2;

    public static boolean isFastClick(int id) {
        if (pos == id) {
            boolean flag = false;
            long curClickTime = System.currentTimeMillis();
            if ((curClickTime - lastClickTime) >= MIN_CLICK_DELAY_TIME) {
                flag = true;
                lastClickTime = curClickTime;
            }
//            pos = -1;
            return flag;
        } else {
            pos=id;
            lastClickTime = System.currentTimeMillis();
            return true;
        }

    }

    public static boolean isFastClick(int id, long time) {
        Log.e("连点1---", "连点");
        if (pos2 == id) {
            boolean flag = false;
            long curClickTime = System.currentTimeMillis();
            if ((curClickTime - lastClickTime2) >= time) {
                flag = true;
                lastClickTime2 = curClickTime;
                Log.e("连点4---", "连点");
            }
            Log.e("连点2---", "连点");
            return flag;
        } else {
            Log.e("连点3---", "连点");
            pos2 = id;
            lastClickTime2 = System.currentTimeMillis();
            return true;
        }

    }
}
